﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Web;
using System.Web.Hosting;
using System.Reflection;

namespace AspNetHost
{
	public class AspHost : MarshalByRefObject
	{
		public AspHost()
		{ }

		public void Process(string page, string query, StreamWriter writer)
		{
			try
			{
				SimpleWorkerRequest request = new SimpleWorkerRequest(page, query, writer);
				HttpRuntime.ProcessRequest(request);
			}
			catch
			{ }
		}

		public string Process(string page, string query)
		{
			try
			{
				TextWriter writer = new StringWriter();
				SimpleWorkerRequest request = new SimpleWorkerRequest(page, query, writer);
				HttpRuntime.ProcessRequest(request);

				writer.Flush();
				writer.Close();

				return writer.ToString();
			}
			catch
			{ }

			return String.Empty;
		}
	}
}
